package Lotr.game.Entity;

import Lotr.game.Animation;
import Lotr.game.Path;
import Lotr.game.Path.PathPoint;
import Lotr.game.Resources;
import java.awt.Graphics;
import java.awt.Image;

public class Enemy {

    public static final int TROLL = 0;
    public static final int URUK = 1;
    public static final int ORK = 2;
    public static final int DRAGON = 3;
    public static final int WARG = 4;
    public static final int LEFT = -1;
    public static final int RIGHT = 1;
    public static final int UP = -1;
    public static final int DOWN = 1;
    protected int health, speed;
    protected int posX, posY;
    protected int directionX, directionY;
    protected int width, height;
    protected boolean visible;
    protected Path path;
    protected int currentPathPoint;
    protected Image sprite;
    protected int direction;
    protected int type;
    protected Resources res;
    protected Animation animation;
    protected int damage;
    protected int id;
    
    public void update() {
       if(currentPathPoint >= path.getPathPointCount()){
           path.enemyReachedEnd(this, damage);
           damage = 0;
           return;
       }
       PathPoint pp = path.getPathPoint(currentPathPoint);
       direction = pp.getDirection();
       directionX = pp.getDirectionX();
       directionY = pp.getDirectionY();
       posX += speed * directionX;
       posY += speed * directionY;
       if(posX == pp.getEndX() && posY == pp.getEndY()){
           currentPathPoint++;
       }
       animation.nextImage();
    }

    public void render(Graphics g) {
        if (!visible) {
            return;
        }
        //g.setColor(Color.red);
        //g.fillRect(posX, posY, width, height);
        g.drawImage(animation.getCurrentImage(), posX, posY, width, height,null);
    }

    public int getType() {
        return type;
    }
    
    public Resources getResources(){
        return res;
    }
    
    public int getDirection(){
        return direction;
    }
    
    public int getWidth(){
        return width;
    }
    
    public int getHeight(){
        return height;
    }
    
}
